package edu.nf.hotel.region.impl;

import edu.nf.hotel.region.CityType;
import edu.nf.hotel.region.CityTypeService;
import edu.nf.hotel.regiondao.CityTypeDao;
import edu.nf.hotel.regiondao.impl.CityTypeDaoImpl;
import edu.nf.hotel.util.PageUtils;
import edu.nf.hotel.vo.PageVO;

import java.util.List;

/**
 * @Date 2023-06-20
 * @Author 带土
 */
public class CityTypeServiceImpl implements CityTypeService {
    @Override
    public PageVO<List<CityType>> listCity(int page, int limit) {
        //先根据page计算出从表的第几条开始查询
        int numberOf = PageUtils.toNumberOf(page, limit);
        //创建DAO实例
        CityTypeDao dao = new CityTypeDaoImpl();
        List<CityType> list = dao.listCity(numberOf, limit);
        Long count = dao.count();
        //将数据封装成PageVo对象并返回
        return PageUtils.toPageVO(list,count);
    }
}
